
/**
 * 
 */
class MyCookie {
	constructor(key, value, time) {
		this.setCookie(key, value, time)
	}
	setCookie(key = '', value = '', time = 5) {
		if (typeof value === 'object') {
			value = JSON.stringify(value)
		}
		const d = new Date()
		d.setTime(d.getTime() - 1000 * 60 ** 2 * 8 + 1000 * time)
		document.cookie = `${key}=${value}; expires=${d}`
	}
	getCookie(queryKey) {
		let tmpArr = document.cookie.split('; ')
		for (let msg of tmpArr) {
			let [key, value] = msg.split("=")
			if (queryKey === key) return value
		}
	}
	removeCookie(key) {
		setCookie(key, null, -1)
	}
}